const http = require('http');
const fs = require('fs');

const server = http.createServer();
let wwwDir = 'F:/www';
server.on('request',function (req,res) {
    let url = req.url
    fs.readFile('./template.html',function (err,data) {  
        if (err) {
            res.end('404 Not Found');
        }

        fs.readdir(wwwDir,function (err,files) {
            if (err) {
                return res.end('Cannot find www dir.')    
            }
            console.log(files);
        });
        res.end(data);
    });
    
});

server.listen('9000',function () {
    console.log('server is running on port 9000.');
});